cmake_minimum_required(VERSION 3.30)

get_fileName_component(dirName ${CMAKE_CURRENT_LIST_DIR} NAME)
get_fileName_component(pathName ${CMAKE_CURRENT_LIST_DIR} PATH)
get_fileName_component(parentDirName ${pathName} NAME)

set(toolProjectName "${parentDirName}_${dirName}")
project(${toolProjectName})
message(STATUS "do <${PROJECT_NAME}>")

file(GLOB embed_files "${CMAKE_CURRENT_LIST_DIR}/*.txt")

foreach(embed_file ${embed_files})
    get_fileName_component(fileName ${embed_file} NAME_WE)
    get_fileName_component(fileExt ${embed_file} EXT)
    set(embeddable_file "${CMAKE_CURRENT_BINARY_DIR}/../embeddable/${fileName}${fileExt}")

    if (${embed_file} IS_NEWER_THAN  ${embeddable_file})
        file(READ ${embed_file} content)
        message(STATUS "embed_file = ${embed_file}")

        set(delim "for_c++_include")
        set(content "R\"${delim}(\n${content})${delim}\"")
        file(WRITE ${embeddable_file} "${content}")
        message(STATUS "embeddable_file = ${embeddable_file}")
    endif()

endforeach()